package com.ycw.wach;

import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;

public class MyWatch implements Watcher {

    private ZooKeeper zooKeeper;

    public MyWatch(ZooKeeper zooKeeper) {
        this.zooKeeper = zooKeeper;
    }

    @Override
    public void process(WatchedEvent event) {
        try {
            zooKeeper.exists(event.getPath(),this);
        } catch (KeeperException | InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(event);
    }
}
